import axios from 'axios';

axios.defaults.baseURL = 'http://localhost:8081'

export const getRepairCostStatisticsApi = (periodType) => {
    return axios.get(`/carsys/repairOrder/statistics/${periodType}`);
}

export const updateOrderStatusApi = (order) => {
    return axios.put(`/carsys/repairOrder/updateStatus`, order);
};

export const deleteOrderApi = (orderId) => {
    return axios.delete(`/carsys/repairOrder/deleteOrder/${orderId}`);
};

export const getRepairOrderByIdApi = (orderId) => {
    return axios.get(`/carsys/repairOrder/${orderId}`);
}

export const getAllOrdersApi = () => {
    return axios.get('/carsys/repairOrder/getAllOrders')
}

export const getAllAssignmentsApi = () => {
    return axios.get('/carsys/assignment/getAllAssignments')
}

export const getAssignmentByIdApi = (assignmentId) => {
    return axios.get(`/carsys/assignment/byAssignmentId/${assignmentId}`)
}

export const logTimeApi = (assignmentId, time) => {
    return axios.post(`/carsys/assignment/logTime/${assignmentId}/${time}`)
}

export const payRepairOrderApi = (orderId) => {
    return axios.post(`/carsys/repairOrder/payment/${orderId}`)
}

export const getAssignmentsByRepairPersonIdAndStatusApi = (repairPersonId, status) => {
    return axios.get(`/carsys/assignment/byRepairPersonIdAndStatus/${repairPersonId}/${status}`)
}

export const completeAssignmentApi = (assignment_id) => {
    return axios.post(`/carsys/assignment/completeAssignment/${assignment_id}`)
}

export const createOrderApi=(request)=>{
    return axios.post('/carsys/repairOrder/createOrder', request)
}

export const getOrdersOfVehicleApi = (vehicle)=>{
    return axios.get(`/carsys/repairOrder/getOrdersByVehicleId/${vehicle.vehicle_id}`)
}

export const getAllOrdersByUserApi = (userId)=>{
    return axios.get(`/carsys/repairOrder/getOrdersByUserId/${userId}`)
}

export const getAssignmentsOfRepairPersonApi = (repairPersonId)=>{
    return axios.get(`/carsys/assignment/byRepairPersonId/${repairPersonId}`)
}

export const acceptAssignmentApi = (repairPersonId,assignment_id)=>{
    return axios.post(`/carsys/assignment/acceptAssignment/${repairPersonId}/${assignment_id}`)
}

export const refuseAssignmentApi = (repairPersonId,assignment_id)=>{
    return axios.post(`/carsys/assignment/refuseAssignment/${repairPersonId}/${assignment_id}`)
}

export const getAssignmentOfOrderApi = (order_id)=>{
    return axios.get(`/carsys/assignment/byOrderId/${order_id}`)
}

export const commentAssignmentApi = (assignment_id,score)=>{
    return axios.post(`/carsys/assignment/commentAssignment/${assignment_id}/${score}`)
}

export const getRemindRecordApi = (assignment_id)=>{
   return axios.get(`/carsys/remindRecord/getRemindRecord/${assignment_id}`)
}

export const remindApi = (assignment_id)=>{
     return axios.post(`/carsys/remindRecord/remind/${assignment_id}`)
}

export const dealRemindRecordApi = (assignment_id)=>{
     return axios.post(`/carsys/remindRecord/deal/${assignment_id}`)
}